import 'package:screen_protector/screen_protector.dart';
import 'package:whale/helper/utils/util.dart';

class ScreenShotMan {
  static ScreenShotMan instance = ScreenShotMan._interval();
  factory ScreenShotMan() {
    return instance;
  }

  ScreenShotMan._interval() {
    init();
  }

  void init() {
    ScreenProtector.addListener(screenshotListener, screenRecordListener);
  }

  void screenshotListener() {
    if (isDisable) {
      Get.snackbar('温馨提示', '政府机关保密应用不允许截屏');
    }
  }

  void screenRecordListener(bool isRecording) {
    if (isDisable) {
      Get.snackbar('温馨提示', '政府机关保密应用不允许录屏');
    }
  }

  bool isDisable = false;
  bool isDisableWithImage = false;
  bool isDisableWithColor = false;

  Future<void> disable() async {
    await ScreenProtector.preventScreenshotOn();
    isDisable = true;
  }

  Future<void> enable() async {
    await ScreenProtector.preventScreenshotOff();
    isDisable = false;
  }

  // Future<void> protectWithImage() async {
  //   await ScreenProtector.protectDataLeakageOn();
  //   await ScreenProtector.protectDataLeakageWithImage('screenshot');
  //   isDisableWithImage = true;
  // }

  // Future<void> protectWithColorOn() async {
  //   await ScreenProtector.protectDataLeakageOn();
  //   await ScreenProtector.protectDataLeakageWithColor(Colors.white);
  //   isDisableWithColor = true;
  // }

  // Future<void> protectWithColorOff() async {
  //   await ScreenProtector.protectDataLeakageOff();
  //   await ScreenProtector.protectDataLeakageWithColorOff();
  //   isDisableWithColor = false;
  // }
}
